import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
 
public class TMain extends MIDlet implements CommandListener {
  protected TBrowser mBrowser;
	protected TMainMenu mMainMenu;
  protected Command mExitCommand;
  protected Command mBackCommand;
  protected Command mBrowseCommand;
 
  public void startApp() {
    mBackCommand = new Command("Назад", Command.BACK, 1);
    mExitCommand = new Command("Выход", Command.EXIT, 1); //creates the exit command
		mBrowseCommand = new Command("Поиск", Command.ITEM, 1);
		mMainMenu = new TMainMenu(this);
		mMainMenu.browseCommand = mBrowseCommand;
		mMainMenu.addCommand(mExitCommand); //adds the command to the Form
		Display.getDisplay(this).setCurrent(mMainMenu);
  }
 
  public void pauseApp() {
  }
 
  public void destroyApp(boolean unconditional) {
  }
 
  public void commandAction(Command c, Displayable d) {
    if(c == mExitCommand) this.notifyDestroyed();
		else if(c == mBackCommand) Display.getDisplay(this).setCurrent(mMainMenu);
		else if(c == mBrowseCommand) {
			if(mBrowser==null) {
				mBrowser = new TBrowser(this);
				mBrowser.addCommand(mBackCommand); //adds the command to the Form
			}
			Display.getDisplay(this).setCurrent(mBrowser);
		}
  }    
}